<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>找回密码</title>
    <include file="Common:header_include"/>
</head>
<body>
<!--顶部开始-->
<include file="Common:header"/>
<!--顶部结束-->
<!--主体内容开始-->
<div class="pwd_main register preset">
    <div class="row bt">
        <div class="col-xs-2"></div>
        <div class="col-xs-9"><span class="glyphicon glyphicon-lock" style="color:#e4393c; margin-right:10px;"></span>找回密码</div>
    </div>
    <div class="row">
        <div class="col-xs-3"></div>
        <div class=" col-xs-9" style="margin:15px 0;">找回您的密码<span style="color: red;">（以下信息*皆为必填项，请认真填写）</span></div>
    </div>
    <form  class="form form-horizontal va-m Validform " id="demoform-1" >
        <div class="form-group">
            <label class="col-xs-4 control-label"><i style="color: #e4393c">*</i>&nbsp;&nbsp;手机号码：</label>
            <div class="col-xs-5">
                <input type="text" class="form-control" id="phone" name="phone" autocomplete="off" placeholder="请输入手机号码" datatype="m" errormsg="请输入正确的手机号">
            </div>
            <div class="col-xs-3">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label"><i style="color: #e4393c">*</i>&nbsp;&nbsp;验证码：</label>
            <div class="col-xs-2">
                <input type="text" class="form-control"  id="messages" name="messages" autocomplete="off" placeholder="请输入验证码" datatype="n6-6" errormsg="请输入验证码" disabled>
            </div>
            <div class="col-xs-2">
            </div>
            <div class="col-xs-1 ">
                <input class="btn btn-primary radius" type="button" style="background: #00b683;border-color: #00b683;margin-left: -51%" value="获取验证码" onclick="sendmsg(this)">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label"><i style="color: #e4393c">*</i>&nbsp;&nbsp;重置密码：</label>
            <div class="col-xs-5">
                <input type="password" class="form-control" name="passwd" id="passwd" autocomplete="off" placeholder="再次输入密码 " datatype="s6-12" nullmsg="请输入6-12位字符" errormsg="密码至少6个字符,最多12个字符">
            </div>
            <div class="col-xs-3">
            </div>
        </div>
        <div class="form-group" style="margin-top: 50px">
            <div class="col-xs-2 col-xs-offset-4">
                <input class="btn btn-primary form-control"   value="立即重置"  onclick="resetpwd()"  style="background: #00b683;border-color: #00b683;padding: 0 40px">
            </div>
        </div>
    </form>
</div>
<!--主体内容结束-->
<!--尾部开始-->
<include file="Common:footer"/>
<!--尾部结束-->
</body>
<script>
    $(".pwdform").Validform({
        tiptype:2
    });
    function  sendmsg(obj) {
        var ajaxurl = "{:U(sendmsg)}";
        $phone=$("#phone").val();
        if(verification($phone)){
            $("#messages").removeAttr("disabled");
            $.ajax({
                url:ajaxurl,
                data:{
                    phone:$phone
                },
                type:"Post",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg);
                    settime(obj);
                }
            });
        }else{
            layer.msg('请输入正确的手机号!')
        }
    }
    /**
     * 重置密码
     */
    function  resetpwd() {
        $phone=$("#phone").val();
        if(verification($phone) && $("#messages").val() && $("#passwd").val()){
            var url = "{:U('DoctorInfo/restpassword')}";
            $.ajax({
                url:url,
                type:"Post",
                data: $("#demoform-1").serialize(),
                dataType:"json",
                success: function(data) {
                    if(data.status==1){
                        layer.msg(data.msg, function(){
                            window.location.href="{:U('login')}";
                        });
                    }else{
                        layer.msg(data.msg);
                    }
                },
                error:function () {
                    layer.msg('请检查您的验证码是否正确');
                }
            });
        }else{
            layer.msg('请完善你的修改信息!');
        }
    }
</script>
</html>